package pacBiopackage;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class ObjectSerializing<T> 
{
	
	public void serializeObject(T ks,String filenameOutput)
	{
		try
		{
			FileOutputStream fout = new FileOutputStream(filenameOutput);
			ObjectOutputStream oos = new ObjectOutputStream(fout);
			oos.writeObject(ks);
			oos.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}		
	}
	
	@SuppressWarnings("unchecked")
	public T deserializeObject(T ks,String filenameInput)
	{
		try
		{
			FileInputStream fin = new FileInputStream(filenameInput);
			ObjectInputStream ois = new ObjectInputStream(fin);
			ks = (T) ois.readObject();
			ois.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return ks;
	}

}
